package com.dayilyword.service.impl;

import com.dayilyword.entity.Msg;
import com.dayilyword.mapper.MsgMapper;
import com.dayilyword.service.BaseService;
import com.dayilyword.service.MsgService;
import com.dayilyword.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class MsgServiceImpl implements MsgService {
    @Autowired
    MsgMapper msgMapper;

    @Override
    public void publishMsg(int userId, String publishMsg) {
        Msg msg = new Msg();
        msg.setUserid(userId);
        msg.setCreate_time(System.currentTimeMillis());
        msg.setMsg(publishMsg);
        msgMapper.insertSelective(msg);
    }

    @Override
    public void disableMsg(int msgId) {
        Msg msg = new Msg();
        msg.setId(msgId);
        msg.setIs_delete(0);
        msgMapper.insertSelective(msg);
    }

    @Override
    public void putMsg(int msgId, String publishMsg) {
        Msg msg = new Msg();
        msg.setId(msgId);
        msg.setMsg(publishMsg);
        msgMapper.updateByPrimaryKeySelective(msg);

    }


    @Override
    public List<HashMap<String, Object>> getAttentionMsgList(int firstIndex, int lastIndex, int userId) {

        return msgMapper.getAttentionMsgList(firstIndex, lastIndex, userId);
    }

    @Override
    public List<HashMap<String, Object>> getUserHistoryMsgList(int firstIndex, int lastIndex, int userId) {

        return msgMapper.getUserHistoryMsgList(firstIndex, lastIndex, userId);
    }

}
